package com.libre.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.libre.business.entity.Form;
import com.libre.business.mapper.FormMapper;
import com.libre.business.service.FormService;
import com.libre.common.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FormServiceImpl extends ServiceImpl<FormMapper, Form> implements FormService {

    @Override
    public IPage<Form> findPage(Page page, Form form) {
        QueryWrapper<Form> queryWrapper = new QueryWrapper<>();
        if (StringUtil.isNotEmpty(form.getName())) queryWrapper.like("name", form.getName());
        queryWrapper.eq("is_delete", "0");
        Page pages = this.page(page, queryWrapper);
        return pages;
    }

    @Override
    public List<Form> findList(Form form) {
        QueryWrapper<Form> queryWrapper = new QueryWrapper<>();
        if (StringUtil.isNotEmpty(form.getName())) queryWrapper.like("name", form.getName());
        queryWrapper.eq("is_delete", "0");
        List<Form> list = this.list(queryWrapper);
        return list;
    }
}
